package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper  extends BaseMapper<Order> {

    @Select("SELECT count(1) FROM t_order WHERE MEMBER_ID = #{memberId} AND ORDERDATE = #{orderDate} AND SETMEAL_ID = #{setmealId}")
    int queryOrderIsExist(@Param("memberId") Integer memberId,@Param("orderDate") String orderDate,@Param("setmealId") int setmealId);

    @Select("SELECT t2.name AS member,t1.ORDERDATE AS orderDate,t1.ORDERTYPE AS orderType, t3.name AS setmeal FROM t_order t1, t_member t2, t_setmeal t3 WHERE t1.ID = #{id} AND t1.MEMBER_ID = t2.ID AND t1.SETMEAL_ID = t3.ID")
    Map findOrderInfoByorderId(@Param("id")Integer id);
}
